package bsw.wode.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import bsw.util.TransportObject;
import bsw.wode.entity.WodeUser;

public class UserDAO extends BaseDAO<WodeUser> {
  
	@SuppressWarnings("unchecked")
	public WodeUser findUserByLoginName(String loginName)
	{
		Criteria criteria = this.getSession().createCriteria(WodeUser.class);
		criteria.add(Restrictions.eq("loginName", loginName));
		TransportObject searchResult =  findList(criteria, null, 0, 1);
		if(searchResult.getTotalRecords() >0)
		{
			return (WodeUser)((List)searchResult.getResultCollection()).get(0);
		}
		return null;
	}
}